package model

import "gpt-api/framework/db"

type City struct {
	db.BaseModel
	Code         string `json:"code" gorm:"column:code;type:varchar(255);default:'';comment:code"`
	Name         string `json:"name" gorm:"column:name;type:varchar(255);default:'';comment:name"`
	Provincecode string `json:"provincecode" gorm:"column:provincecode;type:varchar(255);default:'';comment:provincecode"`
}

func (City) TableName() string {
	return "city"
}

// 根据Provincecode查询所有城市
func (m City) GetCityByProvinceCode(database *db.DB, provincecode string) ([]City, error) {
	var city []City
	err := database.Where("provincecode = ?", provincecode).Find(&city).Error
	return city, err
}
